/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.koller.million.grid.frame.plyManag;

import de.koller.million.grid.engine.player.Player;
import java.awt.Color;
import java.awt.Component;
import java.util.Iterator;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

/**
 *
 * @author User
 */
public class PMPlayerPanel extends javax.swing.JPanel implements ListCellRenderer<Player> {

	private Player player;
			
	public PMPlayerPanel() {
		this.player = null;
		initComponents();
	}

	@Override
	public Component getListCellRendererComponent( JList<? extends Player> list, Player value, int index, boolean isSelected, boolean cellHasFocus ) {
		if( value != null )
			this.jLabel1.setText( value.name );
		
		if( index % 2 == 0 )
			this.setBackground( new Color( 0xfff0f0f0 ) );
		else
			this.setBackground( new Color( 0xffe0e0e0 ) );
		
		if( isSelected )
			this.setBackground( new Color( 0xff9090ff ) );
		
		String ig = "";
		for( Iterator<Integer> i = value.getGrp().iterator(); i.hasNext(); ) {
			ig += (char)( (int)i.next() );
			if( i.hasNext() ) ig += ",";
		}
		ig += " ";
		this.grpIn.setText( ig );
		return this;
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings( "unchecked" )
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        grpIn = new javax.swing.JLabel();

        jLabel1.setText("Name");

        grpIn.setFont(new java.awt.Font("Tahoma", 2, 10)); // NOI18N
        grpIn.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        grpIn.setText("A,B,C,D,E,F ");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(grpIn, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(grpIn))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel grpIn;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables
}
